+Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.[ch]: Removed has_cursor, set the cursor
+ beginning of Text when creating the Text widget.
+
+ * gtk/testgtk.c: Grab the focus on the text widget so
+ as to test out the above.
+
+Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16.
+ ::changed is a notification signal and should have no default
+ handler. A complete redraw of the Text widget does _not_ need to
+ be done on every text insertion.
+
+Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com>
+ (gtk-abilleira-072198-patch)
+
+ * gtk/gtkwindow.[ch]:
+ Add gtk_window_set_modal() which sets a flag; when
+ set the window does a gtk_grab_add() when the window
+ is shown, and a gtk_grab_remove() when the window
+ is hidden.
+
+ * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in
+ that case will run "Create Dir","Delete File" and "Rename File"
+ dialogs as modal too.
+
+ * gtk/testgtk.c: Added a button with an example of creating modal
+ dialog boxes. Including file selection and color selection standard
+ dialogs.
+
+Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c:
+ Removed CAN_FOCUS by default from scrollbars, button
+ children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children)
+ (Scrollbar definitely good change, toolbar bit more questionable)
+
Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org>
* examples/packbox/packbox.c: #include fixes (reported by Asbjoern
+Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.[ch]: Removed has_cursor, set the cursor
+ beginning of Text when creating the Text widget.
+
+ * gtk/testgtk.c: Grab the focus on the text widget so
+ as to test out the above.
+
+Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16.
+ ::changed is a notification signal and should have no default
+ handler. A complete redraw of the Text widget does _not_ need to
+ be done on every text insertion.
+
+Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com>
+ (gtk-abilleira-072198-patch)
+
+ * gtk/gtkwindow.[ch]:
+ Add gtk_window_set_modal() which sets a flag; when
+ set the window does a gtk_grab_add() when the window
+ is shown, and a gtk_grab_remove() when the window
+ is hidden.
+
+ * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in
+ that case will run "Create Dir","Delete File" and "Rename File"
+ dialogs as modal too.
+
+ * gtk/testgtk.c: Added a button with an example of creating modal
+ dialog boxes. Including file selection and color selection standard
+ dialogs.
+
+Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c:
+ Removed CAN_FOCUS by default from scrollbars, button
+ children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children)
+ (Scrollbar definitely good change, toolbar bit more questionable)
+
Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org>
* examples/packbox/packbox.c: #include fixes (reported by Asbjoern
+Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.[ch]: Removed has_cursor, set the cursor
+ beginning of Text when creating the Text widget.
+
+ * gtk/testgtk.c: Grab the focus on the text widget so
+ as to test out the above.
+
+Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16.
+ ::changed is a notification signal and should have no default
+ handler. A complete redraw of the Text widget does _not_ need to
+ be done on every text insertion.
+
+Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com>
+ (gtk-abilleira-072198-patch)
+
+ * gtk/gtkwindow.[ch]:
+ Add gtk_window_set_modal() which sets a flag; when
+ set the window does a gtk_grab_add() when the window
+ is shown, and a gtk_grab_remove() when the window
+ is hidden.
+
+ * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in
+ that case will run "Create Dir","Delete File" and "Rename File"
+ dialogs as modal too.
+
+ * gtk/testgtk.c: Added a button with an example of creating modal
+ dialog boxes. Including file selection and color selection standard
+ dialogs.
+
+Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c:
+ Removed CAN_FOCUS by default from scrollbars, button
+ children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children)
+ (Scrollbar definitely good change, toolbar bit more questionable)
+
Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org>
* examples/packbox/packbox.c: #include fixes (reported by Asbjoern
+Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.[ch]: Removed has_cursor, set the cursor
+ beginning of Text when creating the Text widget.
+
+ * gtk/testgtk.c: Grab the focus on the text widget so
+ as to test out the above.
+
+Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16.
+ ::changed is a notification signal and should have no default
+ handler. A complete redraw of the Text widget does _not_ need to
+ be done on every text insertion.
+
+Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com>
+ (gtk-abilleira-072198-patch)
+
+ * gtk/gtkwindow.[ch]:
+ Add gtk_window_set_modal() which sets a flag; when
+ set the window does a gtk_grab_add() when the window
+ is shown, and a gtk_grab_remove() when the window
+ is hidden.
+
+ * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in
+ that case will run "Create Dir","Delete File" and "Rename File"
+ dialogs as modal too.
+
+ * gtk/testgtk.c: Added a button with an example of creating modal
+ dialog boxes. Including file selection and color selection standard
+ dialogs.
+
+Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c:
+ Removed CAN_FOCUS by default from scrollbars, button
+ children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children)
+ (Scrollbar definitely good change, toolbar bit more questionable)
+
Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org>
* examples/packbox/packbox.c: #include fixes (reported by Asbjoern
+Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.[ch]: Removed has_cursor, set the cursor
+ beginning of Text when creating the Text widget.
+
+ * gtk/testgtk.c: Grab the focus on the text widget so
+ as to test out the above.
+
+Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16.
+ ::changed is a notification signal and should have no default
+ handler. A complete redraw of the Text widget does _not_ need to
+ be done on every text insertion.
+
+Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com>
+ (gtk-abilleira-072198-patch)
+
+ * gtk/gtkwindow.[ch]:
+ Add gtk_window_set_modal() which sets a flag; when
+ set the window does a gtk_grab_add() when the window
+ is shown, and a gtk_grab_remove() when the window
+ is hidden.
+
+ * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in
+ that case will run "Create Dir","Delete File" and "Rename File"
+ dialogs as modal too.
+
+ * gtk/testgtk.c: Added a button with an example of creating modal
+ dialog boxes. Including file selection and color selection standard
+ dialogs.
+
+Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c:
+ Removed CAN_FOCUS by default from scrollbars, button
+ children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children)
+ (Scrollbar definitely good change, toolbar bit more questionable)
+
Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org>
* examples/packbox/packbox.c: #include fixes (reported by Asbjoern
+Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.[ch]: Removed has_cursor, set the cursor
+ beginning of Text when creating the Text widget.
+
+ * gtk/testgtk.c: Grab the focus on the text widget so
+ as to test out the above.
+
+Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16.
+ ::changed is a notification signal and should have no default
+ handler. A complete redraw of the Text widget does _not_ need to
+ be done on every text insertion.
+
+Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com>
+ (gtk-abilleira-072198-patch)
+
+ * gtk/gtkwindow.[ch]:
+ Add gtk_window_set_modal() which sets a flag; when
+ set the window does a gtk_grab_add() when the window
+ is shown, and a gtk_grab_remove() when the window
+ is hidden.
+
+ * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in
+ that case will run "Create Dir","Delete File" and "Rename File"
+ dialogs as modal too.
+
+ * gtk/testgtk.c: Added a button with an example of creating modal
+ dialog boxes. Including file selection and color selection standard
+ dialogs.
+
+Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c:
+ Removed CAN_FOCUS by default from scrollbars, button
+ children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children)
+ (Scrollbar definitely good change, toolbar bit more questionable)
+
Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org>
* examples/packbox/packbox.c: #include fixes (reported by Asbjoern
+Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.[ch]: Removed has_cursor, set the cursor
+ beginning of Text when creating the Text widget.
+
+ * gtk/testgtk.c: Grab the focus on the text widget so
+ as to test out the above.
+
+Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16.
+ ::changed is a notification signal and should have no default
+ handler. A complete redraw of the Text widget does _not_ need to
+ be done on every text insertion.
+
+Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com>
+ (gtk-abilleira-072198-patch)
+
+ * gtk/gtkwindow.[ch]:
+ Add gtk_window_set_modal() which sets a flag; when
+ set the window does a gtk_grab_add() when the window
+ is shown, and a gtk_grab_remove() when the window
+ is hidden.
+
+ * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in
+ that case will run "Create Dir","Delete File" and "Rename File"
+ dialogs as modal too.
+
+ * gtk/testgtk.c: Added a button with an example of creating modal
+ dialog boxes. Including file selection and color selection standard
+ dialogs.
+
+Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c:
+ Removed CAN_FOCUS by default from scrollbars, button
+ children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children)
+ (Scrollbar definitely good change, toolbar bit more questionable)
+
Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org>
* examples/packbox/packbox.c: #include fixes (reported by Asbjoern
class->insert_text = NULL;
class->delete_text = NULL;
- class->changed = (void (*) (GtkEditable*)) gtk_widget_queue_draw;
class->activate = NULL;
class->set_editable = gtk_editable_real_set_editable;
(gpointer) fs);
gtk_window_set_title (GTK_WINDOW (dialog), "Create Directory");
gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
- gtk_widget_show (dialog);
-
+
+ /* If file dialog is grabbed, grab option dialog */
+ /* When option dialog is closed, file dialog will be grabbed again */
+ if (GTK_WINDOW(fs)->modal)
+ gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
+
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(vbox), 8);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox,
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
gtk_widget_grab_default(button);
gtk_widget_show (button);
+
+ gtk_widget_show (dialog);
}
static void
(gpointer) fs);
gtk_window_set_title (GTK_WINDOW (dialog), "Delete File");
gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+
+ /* If file dialog is grabbed, grab option dialog */
+ /* When option dialog is closed, file dialog will be grabbed again */
+ if (GTK_WINDOW(fs)->modal)
+ gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(vbox), 8);
gtk_widget_show (button);
gtk_widget_show (dialog);
+
}
static void
(gpointer) fs);
gtk_window_set_title (GTK_WINDOW (dialog), "Rename File");
gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
- gtk_widget_show (dialog);
+
+ /* If file dialog is grabbed, grab option dialog */
+ /* When option dialog closed, file dialog will be grabbed again */
+ if (GTK_WINDOW(fs)->modal)
+ gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(vbox), 8);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
gtk_widget_grab_default(button);
gtk_widget_show (button);
+
+ gtk_widget_show (dialog);
}
GtkRequisition *requisition;
widget = GTK_WIDGET (hscrollbar);
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
requisition = &widget->requisition;
requisition->width = (RANGE_CLASS (widget)->min_slider_size +
text->tab_stops = g_list_prepend (text->tab_stops, (void*)8);
text->tab_stops = g_list_prepend (text->tab_stops, (void*)8);
+ text->line_start_cache = NULL;
+
text->line_wrap = TRUE;
text->word_wrap = FALSE;
text = gtk_type_new (GTK_TYPE_TEXT);
gtk_text_set_adjustments (text, hadj, vadj);
+ gtk_editable_set_position (GTK_EDITABLE (text), 0);
return GTK_WIDGET (text);
}
{
GtkText *text = (GtkText *) editable;
- undraw_cursor( text, FALSE );
- text->has_cursor = 1;
- text->cursor_mark = find_mark( text, position );
- find_cursor( text, TRUE );
- draw_cursor( text, FALSE );
+ undraw_cursor (text, FALSE);
+ text->cursor_mark = find_mark (text, position);
+ find_cursor (text, TRUE);
+ draw_cursor (text, FALSE);
gtk_editable_select_region (editable, 0, 0);
}
key = event->keyval;
return_val = TRUE;
- if ((GTK_EDITABLE(text)->editable == FALSE) || !text->has_cursor)
+ if ((GTK_EDITABLE(text)->editable == FALSE))
{
switch (event->keyval)
{
static void
find_cursor (GtkText* text, gboolean scroll)
{
- if (!text->has_cursor)
- return;
-
- find_line_containing_point (text, text->cursor_mark.index, scroll);
+ if (GTK_WIDGET_REALIZED (text))
+ {
+ find_line_containing_point (text, text->cursor_mark.index, scroll);
- g_assert (text->cursor_mark.index >= text->first_line_start_index);
+ g_assert (text->cursor_mark.index >= text->first_line_start_index);
- if (text->current_line)
- find_cursor_at_line (text,
- &CACHE_DATA(text->current_line),
- pixel_height_of(text, text->current_line));
+ if (text->current_line)
+ find_cursor_at_line (text,
+ &CACHE_DATA(text->current_line),
+ pixel_height_of(text, text->current_line));
+ }
GTK_EDITABLE (text)->current_pos = text->cursor_mark.index;
}
pixel_height = - text->first_cut_pixels;
- text->has_cursor = 1;
-
for (; cache; cache = cache->next)
{
pixel_height += LINE_HEIGHT(CACHE_DATA(cache));
GtkPropertyMark mark;
gint offset;
- if (!text->has_cursor)
- {
- scroll_int (text, count * KEY_SCROLL_PIXELS);
- return;
- }
-
mark = find_this_line_start_mark (text, text->cursor_mark.index, &text->cursor_mark);
offset = text->cursor_mark.index - mark.index;
move_cursor_hor (GtkText *text, int count)
{
/* count should be +-1. */
- if (!text->has_cursor)
- return;
-
if ( (count > 0 && text->cursor_mark.index + count > TEXT_LENGTH(text)) ||
(count < 0 && text->cursor_mark.index < (- count)) ||
(count == 0) )
text->cursor_drawn_level = 0;
if ((text->cursor_drawn_level ++ == 0) &&
- text->has_cursor &&
(editable->selection_start_pos == editable->selection_end_pos) &&
GTK_WIDGET_DRAWABLE (text))
{
static gint
drawn_cursor_min (GtkText* text)
{
- if (text->has_cursor)
- {
- GdkFont* font;
-
- g_assert(text->cursor_mark.property);
-
- font = MARK_CURRENT_FONT(&text->cursor_mark);
-
- return text->cursor_pos_y - text->cursor_char_offset - font->ascent;
- }
- else
- return 0;
+ GdkFont* font;
+
+ g_assert(text->cursor_mark.property);
+
+ font = MARK_CURRENT_FONT(&text->cursor_mark);
+
+ return text->cursor_pos_y - text->cursor_char_offset - font->ascent;
}
static gint
drawn_cursor_max (GtkText* text)
{
- if (text->has_cursor)
- {
- GdkFont* font;
-
- g_assert(text->cursor_mark.property);
-
- font = MARK_CURRENT_FONT(&text->cursor_mark);
-
- return text->cursor_pos_y - text->cursor_char_offset;
- }
- else
- return 0;
+ GdkFont* font;
+
+ g_assert(text->cursor_mark.property);
+
+ font = MARK_CURRENT_FONT(&text->cursor_mark);
+
+ return text->cursor_pos_y - text->cursor_char_offset;
}
static void
text->cursor_drawn_level = 1;
if ((--text->cursor_drawn_level == 0) &&
- text->has_cursor &&
editable->editable &&
(editable->selection_start_pos == editable->selection_end_pos) &&
GTK_WIDGET_DRAWABLE (text))
draw_line_wrap (text, pixels + CACHE_DATA(cache).font_ascent);
}
- if (cursor && text->has_cursor && GTK_WIDGET_HAS_FOCUS (text))
+ if (cursor && GTK_WIDGET_HAS_FOCUS (text))
{
if (CACHE_DATA(cache).start.index <= text->cursor_mark.index &&
CACHE_DATA(cache).end.index >= text->cursor_mark.index)
/* FLAGS */
- /* True iff the cursor has been placed yet. */
- guint has_cursor : 1;
/* True iff this buffer is wrapping lines, otherwise it is using a
* horizontal scrollbar. */
guint line_wrap : 1;
GtkRequisition *requisition;
widget = GTK_WIDGET (vscrollbar);
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
requisition = &widget->requisition;
requisition->width = (RANGE_CLASS (widget)->slider_width +
#include "gtksignal.h"
#include "gtkwindow.h"
#include "gtkbindings.h"
+#include "gtkmain.h"
enum {
SET_FOCUS,
window->handling_resize = FALSE;
window->position = GTK_WIN_POS_NONE;
window->use_uposition = TRUE;
+ window->modal = FALSE;
gtk_container_register_toplevel (GTK_CONTAINER (window));
}
return FALSE;
}
+void
+gtk_window_set_modal (GtkWindow *window, gboolean modal)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ /* If the widget was showed already, adjust it's grab state */
+ if (GTK_WIDGET_VISIBLE(GTK_WIDGET(window)))
+ {
+ if (window->modal && !modal)
+ gtk_grab_remove (GTK_WIDGET(window));
+ else if (!window->modal && modal)
+ gtk_grab_add (GTK_WIDGET(window));
+ }
+
+ window->modal = modal;
+}
+
static void
gtk_window_shutdown (GtkObject *object)
{
GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
gtk_container_check_resize (GTK_CONTAINER (widget));
gtk_widget_map (widget);
+
+ if (GTK_WINDOW(widget)->modal)
+ gtk_grab_add(widget);
+
}
static void
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
gtk_widget_unmap (widget);
+
+ if (GTK_WINDOW(widget)->modal)
+ gtk_grab_remove(widget);
+
}
static void
guint handling_resize : 1;
guint position : 2;
guint use_uposition : 1;
+ guint modal : 1;
};
struct _GtkWindowClass
gint gtk_window_activate_focus (GtkWindow *window);
gint gtk_window_activate_default (GtkWindow *window);
-
+/* If window is set modal, input will be grabbed when show and released when hide */
+void gtk_window_set_modal (GtkWindow *window,
+ gboolean modal);
#ifdef __cplusplus
}
#endif /* __cplusplus */
}
}
+/*
+ create_modal_window
+ */
+
+static gboolean
+cmw_destroy_cb(GtkWidget *widget)
+{
+ /* This is needed to get out of gtk_main */
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+static void
+cmw_color (GtkWidget *widget)
+{
+ GtkWidget *csd;
+
+ csd=gtk_color_selection_dialog_new ("This is a modal color selection dialog");
+
+ /* Set as modal */
+ gtk_window_set_modal (GTK_WINDOW(csd),TRUE);
+
+ gtk_signal_connect (GTK_OBJECT(csd), "destroy",
+ GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL);
+
+ gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->ok_button),
+ "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (csd));
+ gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->cancel_button),
+ "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (csd));
+
+ /* wait until destroy calls gtk_main_quit */
+ gtk_widget_show (csd);
+ gtk_main ();
+}
+
+static void
+cmw_file (GtkWidget *widget)
+{
+ GtkWidget *fs;
+
+ fs = gtk_file_selection_new("This is a modal file selection dialog");
+
+ /* Set as modal */
+ gtk_window_set_modal (GTK_WINDOW(fs),TRUE);
+
+ gtk_signal_connect (GTK_OBJECT(fs), "destroy",
+ GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL);
+
+ gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
+ "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (fs));
+ gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->cancel_button),
+ "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (fs));
+
+ /* wait until destroy calls gtk_main_quit */
+ gtk_widget_show (fs);
+
+ gtk_main();
+}
+
+
+static void
+create_modal_window (void)
+{
+ GtkWidget *window = NULL;
+ GtkWidget *box1,*box2;
+ GtkWidget *frame1;
+ GtkWidget *btnColor,*btnFile,*btnClose;
+
+ /* Create modal window (Here you can use any window descendent )*/
+ window=gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW(window),"This window is modal");
+
+ /* Set window as modal */
+ gtk_window_set_modal (GTK_WINDOW(window),TRUE);
+
+ /* Create widgets */
+ box1 = gtk_vbox_new (FALSE,5);
+ frame1 = gtk_frame_new ("Standard dialogs in modal form");
+ box2 = gtk_vbox_new (TRUE,5);
+ btnColor = gtk_button_new_with_label ("Color");
+ btnFile = gtk_button_new_with_label ("File Selection");
+ btnClose = gtk_button_new_with_label ("Close");
+
+ /* Init widgets */
+ gtk_container_border_width (GTK_CONTAINER(box1),3);
+ gtk_container_border_width (GTK_CONTAINER(box2),3);
+
+ /* Pack widgets */
+ gtk_container_add (GTK_CONTAINER (window), box1);
+ gtk_box_pack_start (GTK_BOX (box1), frame1, TRUE, TRUE, 4);
+ gtk_container_add (GTK_CONTAINER (frame1), box2);
+ gtk_box_pack_start (GTK_BOX (box2), btnColor, FALSE, FALSE, 4);
+ gtk_box_pack_start (GTK_BOX (box2), btnFile, FALSE, FALSE, 4);
+ gtk_box_pack_start (GTK_BOX (box1), gtk_hseparator_new (), FALSE, FALSE, 4);
+ gtk_box_pack_start (GTK_BOX (box1), btnClose, FALSE, FALSE, 4);
+
+ /* connect signals */
+ gtk_signal_connect_object (GTK_OBJECT (btnClose), "clicked",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ GTK_OBJECT (window));
+
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC (cmw_destroy_cb),NULL);
+
+ gtk_signal_connect (GTK_OBJECT (btnColor), "clicked",
+ GTK_SIGNAL_FUNC (cmw_color),NULL);
+ gtk_signal_connect (GTK_OBJECT (btnFile), "clicked",
+ GTK_SIGNAL_FUNC (cmw_file),NULL);
+
+ /* Show widgets */
+ gtk_widget_show_all (window);
+
+ /* wait until dialog get destroyed */
+ gtk_main();
+}
+
/*
* GtkScrolledWindow
*/
gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ gtk_widget_grab_focus (text);
gtk_widget_show (text);
hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj);
{ "handle box", create_handle_box },
{ "list", create_list },
{ "menus", create_menus },
+ { "modal window", create_modal_window },
{ "notebook", create_notebook },
{ "panes", create_panes },
{ "pixmap", create_pixmap },
}
}
+/*
+ create_modal_window
+ */
+
+static gboolean
+cmw_destroy_cb(GtkWidget *widget)
+{
+ /* This is needed to get out of gtk_main */
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+static void
+cmw_color (GtkWidget *widget)
+{
+ GtkWidget *csd;
+
+ csd=gtk_color_selection_dialog_new ("This is a modal color selection dialog");
+
+ /* Set as modal */
+ gtk_window_set_modal (GTK_WINDOW(csd),TRUE);
+
+ gtk_signal_connect (GTK_OBJECT(csd), "destroy",
+ GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL);
+
+ gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->ok_button),
+ "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (csd));
+ gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->cancel_button),
+ "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (csd));
+
+ /* wait until destroy calls gtk_main_quit */
+ gtk_widget_show (csd);
+ gtk_main ();
+}
+
+static void
+cmw_file (GtkWidget *widget)
+{
+ GtkWidget *fs;
+
+ fs = gtk_file_selection_new("This is a modal file selection dialog");
+
+ /* Set as modal */
+ gtk_window_set_modal (GTK_WINDOW(fs),TRUE);
+
+ gtk_signal_connect (GTK_OBJECT(fs), "destroy",
+ GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL);
+
+ gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
+ "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (fs));
+ gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->cancel_button),
+ "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),
+ GTK_OBJECT (fs));
+
+ /* wait until destroy calls gtk_main_quit */
+ gtk_widget_show (fs);
+
+ gtk_main();
+}
+
+
+static void
+create_modal_window (void)
+{
+ GtkWidget *window = NULL;
+ GtkWidget *box1,*box2;
+ GtkWidget *frame1;
+ GtkWidget *btnColor,*btnFile,*btnClose;
+
+ /* Create modal window (Here you can use any window descendent )*/
+ window=gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW(window),"This window is modal");
+
+ /* Set window as modal */
+ gtk_window_set_modal (GTK_WINDOW(window),TRUE);
+
+ /* Create widgets */
+ box1 = gtk_vbox_new (FALSE,5);
+ frame1 = gtk_frame_new ("Standard dialogs in modal form");
+ box2 = gtk_vbox_new (TRUE,5);
+ btnColor = gtk_button_new_with_label ("Color");
+ btnFile = gtk_button_new_with_label ("File Selection");
+ btnClose = gtk_button_new_with_label ("Close");
+
+ /* Init widgets */
+ gtk_container_border_width (GTK_CONTAINER(box1),3);
+ gtk_container_border_width (GTK_CONTAINER(box2),3);
+
+ /* Pack widgets */
+ gtk_container_add (GTK_CONTAINER (window), box1);
+ gtk_box_pack_start (GTK_BOX (box1), frame1, TRUE, TRUE, 4);
+ gtk_container_add (GTK_CONTAINER (frame1), box2);
+ gtk_box_pack_start (GTK_BOX (box2), btnColor, FALSE, FALSE, 4);
+ gtk_box_pack_start (GTK_BOX (box2), btnFile, FALSE, FALSE, 4);
+ gtk_box_pack_start (GTK_BOX (box1), gtk_hseparator_new (), FALSE, FALSE, 4);
+ gtk_box_pack_start (GTK_BOX (box1), btnClose, FALSE, FALSE, 4);
+
+ /* connect signals */
+ gtk_signal_connect_object (GTK_OBJECT (btnClose), "clicked",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ GTK_OBJECT (window));
+
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC (cmw_destroy_cb),NULL);
+
+ gtk_signal_connect (GTK_OBJECT (btnColor), "clicked",
+ GTK_SIGNAL_FUNC (cmw_color),NULL);
+ gtk_signal_connect (GTK_OBJECT (btnFile), "clicked",
+ GTK_SIGNAL_FUNC (cmw_file),NULL);
+
+ /* Show widgets */
+ gtk_widget_show_all (window);
+
+ /* wait until dialog get destroyed */
+ gtk_main();
+}
+
/*
* GtkScrolledWindow
*/
gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+ gtk_widget_grab_focus (text);
gtk_widget_show (text);
hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj);
{ "handle box", create_handle_box },
{ "list", create_list },
{ "menus", create_menus },
+ { "modal window", create_modal_window },
{ "notebook", create_notebook },
{ "panes", create_panes },
{ "pixmap", create_pixmap },